package com.szjlc.torna.service.impl;

import com.szjlc.torna.entity.Customer;
import com.szjlc.torna.mapper.CustomerMapper;
import com.szjlc.torna.service.CustomerService;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;

/**
 * 客户表(Customer)表服务实现类
 * @author makejava
 * @since 2022-11-19 22:01:09
 */
@Service("customerService")
public class CustomerServiceImpl implements CustomerService {
    @Resource
    private CustomerMapper customerMapper;

    /**
     * 通过ID查询单条数据
     * @param customerId 主键
     * @return 实例对象
     */
    @Override
    public Customer findById(Integer customerId) {
        return this.customerMapper.findById(customerId);
    }

    /**
     * 查询多条数据
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<Customer> queryAllByLimit(int offset, int limit) {
        return this.customerMapper.queryAllByLimit(offset, limit);
    }

    /**
     * 查询所有
     * @return 对象列表
     */
    @Override
    public List<Customer> findAll() {
        return this.customerMapper.findAll();
    }

    /**
     * 新增数据
     * @param customer 实例对象
     * @return 实例对象
     */
    @Override
    public Customer insert(Customer customer) {
        this.customerMapper.insert(customer);
        return customer;
    }

    /**
     * 修改数据
     * @param customer 实例对象
     * @return 实例对象
     */
    @Override
    public Customer update(Customer customer) {
        this.customerMapper.update(customer);
        return this.findById(customer.getCustomerId());
    }

    /**
     * 通过主键删除数据
     * @param customerId 主键
     * @return 是否成功
     */
    @Override
    public void deleteById(Integer customerId) {
        this.customerMapper.deleteById(customerId);
    }
}
